#include <iostream>
#include "../../comlink/link/link.h"
#include "../../comlink/linkslist/linkslist.h"
#include "../../comlink/linkcontrol/linkcontrol.h"
#include "../../processor/processor.h"
#include "../../multprocessor/multprocessor.h"


int main(int argc, char ** argv)
{
  MultProcessor * ProcessorMatrix;

  ProcessorMatrix = new MultProcessor(8,8);

  int ClockCycles = 0;


  ProcessorMatrix->SetProcessorPixel(1,1,1);
  ProcessorMatrix->SetProcessorPixel(1,2,1);
  ProcessorMatrix->SetProcessorPixel(1,3,1);
  ProcessorMatrix->SetProcessorPixel(1,4,1);
  ProcessorMatrix->SetProcessorPixel(1,5,1);
  ProcessorMatrix->SetProcessorPixel(1,6,1);

  ProcessorMatrix->SetProcessorPixel(2,6,1);
  ProcessorMatrix->SetProcessorPixel(3,6,1);
  ProcessorMatrix->SetProcessorPixel(4,6,1);
  ProcessorMatrix->SetProcessorPixel(5,6,1);
  ProcessorMatrix->SetProcessorPixel(6,6,1);

  ProcessorMatrix->SetProcessorPixel(6,5,1);
  ProcessorMatrix->SetProcessorPixel(6,4,1);
  ProcessorMatrix->SetProcessorPixel(6,3,1);
  ProcessorMatrix->SetProcessorPixel(6,2,1);
  ProcessorMatrix->SetProcessorPixel(6,1,1);
  
  ProcessorMatrix->SetProcessorPixel(5,1,1);
  ProcessorMatrix->SetProcessorPixel(4,1,1);
  ProcessorMatrix->SetProcessorPixel(3,1,1);

  ProcessorMatrix->SetProcessorPixel(3,2,1);
  ProcessorMatrix->SetProcessorPixel(3,3,1);
  ProcessorMatrix->SetProcessorPixel(3,4,1);

  ProcessorMatrix->PrintProcessorPixels();

  std::cout << std::endl;

  ProcessorMatrix->PrintProcessorBuildLabels();

  std::cout << std::endl;

  while(!ProcessorMatrix->AreAllProcessorsComplete())
  {
    std::cout << "Cycle: " << ++ClockCycles << std::endl;
    for(int clock = 0; clock < 13; clock++)
    {
      ProcessorMatrix->ClockAllProcessors();
    }
  }

  std::cout << std::endl;

  ProcessorMatrix->PrintProcessorBuildLabels();

  std::cout << std::endl;

  delete ProcessorMatrix;

  return 1;
}
